package org.yu.api.register;

import net.minecraft.world.level.block.LiquidBlock;
import net.minecraftforge.fluids.ForgeFlowingFluid;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;
import java.util.function.Supplier;

public final class FluidHolder implements Supplier<ForgeFlowingFluid> {
    public Supplier<ForgeFlowingFluid.Source> source;
    public Supplier<ForgeFlowingFluid.Flowing> flow;
    public ForgeFlowingFluid.Properties properties;
    @Nullable
    public BlockHolder<? extends LiquidBlock> sourceBlock;

    @Override
    public ForgeFlowingFluid get() {
        return source.get();
    }

    public ForgeFlowingFluid getFlow() {
        return flow.get();
    }

    public Supplier<ForgeFlowingFluid.Source> source() {
        return source;
    }

    public Supplier<ForgeFlowingFluid.Flowing> flow() {
        return flow;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj == null || obj.getClass() != this.getClass()) return false;
        var that = (FluidHolder) obj;
        return Objects.equals(this.source, that.source) &&
                Objects.equals(this.flow, that.flow);
    }

    @Override
    public int hashCode() {
        return Objects.hash(source, flow);
    }

    @Override
    public String toString() {
        return "FluidHolder[" +
                "source=" + source + ", " +
                "flow=" + flow + ']';
    }

}
